package com.dou.sample.fmod_demo_project;

import android.Manifest;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Example of a call to a native method
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M){
            requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 0);
        }
    }

    public void play(View view) {

        int type = 0;
        switch (view.getId()){
            case R.id.normal:
                type = VoiceTool.TYPE_NORMAL;
                break;
            case R.id.luoli:
                type = VoiceTool.TYPE_LUOLI;
                break;
            case R.id.dashu:
                type = VoiceTool.TYPE_DASHU;
                break;
            case R.id.jingsong:
                type = VoiceTool.TYPE_JINGSONG;
                break;
            case R.id.gaoguai:
                type = VoiceTool.TYPE_GAOGUAI;
                break;
            case R.id.kongling:
                type = VoiceTool.TYPE_KONGLING;
                break;
        }

        final String path = Environment.getExternalStorageDirectory() + "/neoRecorder/录音01.mp3";
        final int finalType = type;
        new Thread(new Runnable() {
            @Override
            public void run() {
                VoiceTool.changeVoice(path, finalType);
            }
        }).start();
    }
}
